package com.yanghang.controller;

import com.yanghang.entity.Exam;
import com.yanghang.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/exams")
public class ExamController {
    @Autowired
    private ExamService es;

    @PostMapping
    public void insert(@RequestBody  Exam exam){
        es.insert(exam);
    }
    @DeleteMapping("/{id}")
    public void delete(@PathVariable("id") int id){
        es.delete(id);
    }
    @PutMapping
    public void update(@RequestBody Exam exam){
        es.update(exam);
    }
    @GetMapping
    public List<Exam > selectAll(){
        return es.selectAll();
    }
    @GetMapping("/{id}")
    public Exam selectOne(@PathVariable("id") int id){
        return es.selectOne(id);
    }
}
